/*****************************************************************************

                 ,//////,   ,////    ,///' /////,
                ///' ./// ///'///  ///,    ,, //
               ///////,  ///,///   '/// //;''//,
             ,///' '///,'/////',/////'  /////'\\,

    Copyright 2010 Marcus Jansson <mjansson256@yahoo.se>

    This file is part of ROSA - Realtime Operating System for AVR32.

    ROSA is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ROSA is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ROSA.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
/* Tab size: 4 */

#ifndef _ROSA_TIMER_H_
#define _ROSA_TIMER_H_

#include <avr32/io.h>

//Timer period variables, defined in rosa_tim_asm.S
extern int timerPrescale;
extern int timerRC;

/***********************************************************
 * Kernel timer functions, implemented in rosa_tim_asm.S
 ***********************************************************/
/// Parameter: Tick period in milliseconds
extern void timerInit(unsigned int);
extern void timerReset(void);
extern void timerStart(void);
extern void timerStop(void);
extern void timerPrescaleSet(int);
extern void timerRCSet(int);
extern void timerClearInterrupt(void);

// Functions implemented in rosa_tim.c:

//Timer period functions
int timerPeriodSet(unsigned int ms);

/// Returns the total amount of time (in periods of the TC0 93750 Hz clock)
unsigned int getTotalSystickTime(void);

//Timer interrupt service routine
__attribute__((__interrupt__)) extern void timerISR(void);

#endif /* _ROSA_TIMER_H_ */
